from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter


from . import views,reset_password


urlpatterns = [
    # 注册用户
    url(r'^users/$', views.UserView.as_view()),
    # 验证用户名
    url(r'^usernames/(?P<username>\w{5-20})/count/$', views.UsernameCountView.as_view()),
    # 验证手机号
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),

    # jwt 登录
    # 账号密码登录时需要做cookie购物车数据需要合并到redis库
    # url(r'^authorizations/$', obtain_jwt_token),
    url(r'^authorizations/$', views.UserAuthorizeView.as_view()),
    # 获取用户个人信息
    url(r'^user/$', views.UserDetailView.as_view()),
    # 保存邮箱
    url(r'^email/$', views.EmailView.as_view()),
    # 激活邮箱
    url(r'^emails/verification/$', views.EmailVerifyView.as_view()),
    # 浏览记录
    url(r'^browse_histories/$', views.UserBrowseHistoryView.as_view()),
    # 修改密码
    url(r'^users/(?P<user_id>\d+)/changepassword/$',reset_password.ChangePasswordView.as_view()),
]

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')
urlpatterns += router.urls